<template>
	<view>
		<examine-nav @rightClick="showOverPopup" @leftClick="navLeftClick"></examine-nav>
		<view v-if="recode.length !== 0">
			<rules :number="examineNum + todayNum"></rules>
			<!-- 动态 -->
			<dynamicItem ifShowImg v-for="(item,index) in recode" :key="index" :dynamicDate="item" :imgs="item.fileName === '' ? [] : item.fileName.split(',')"></dynamicItem>
			
			<!-- 通过or不通过按钮 -->
			<view class="btn box-pading">
				<errOrSuccessBtn @btnErrClick="btnErrClick" @btnSuccessClick="btnSuccessClick"></errOrSuccessBtn>
			</view>

			<view class="bottom">

				<view class="bottom-title f-xs">
					其他操作
				</view>

				<view class="bottom-main flex-no-horizontal">

					<view class="bottom-main-item f-xs" @click="banClick">
						<image
							:src="ifBan ? '../../static/img/examine-ban-hover.png' : '../../static/img/examine-ban.png'"
							mode=""></image>
						<view>
							建议封禁
						</view>
					</view>

					<view class="bottom-main-item f-xs" @click="excellentClick">
						<image
							:src="ifExcellent ? '../../static/img/examine-excellent-hover.png' : '../../static/img/examine-excellent.png'"
							mode=""></image>
						<view>
							建议加精
						</view>
					</view>

				</view>

			</view>

			<!-- 不通过理由 -->
			<u-action-sheet :actions="failList" :title="failTitle" :show="failShow" :round="20" :cancelText="'取消'"
				@select="selectBanClick" @close="failHide" :closeOnClickAction="true"></u-action-sheet>
			<!-- 封禁  -->
			<complaint :PopupShow="isShowBanPopup" title="请输入建议封禁理由"
			confirmBgColor="#000000" :isTypeComplaint="false"
			@closeComplaint="isShowBanPopup = false,ifBan = false" @confirm="handleBan"></complaint>
			<!-- 加精 -->
			<complaint :PopupShow="isShowExcellentPopup" title="请输入建议加精理由"
			confirmBgColor="#000000" :isTypeComplaint="false"
			@closeComplaint="isShowExcellentPopup = false,ifExcellent = false" @confirm="handleExcellent"></complaint>
			
		</view>
		
		<view class="empty" v-else>
			<view>
				<image src="../../static/empty/index-empty.png" mode=""></image>
			</view>
			<view>暂无审核</view>
		</view>
		
		<!-- 结束审核弹窗 -->
		<tips-popup :show="isShowOver" :ifShowCancel="true"
		@btnSuccessClick="confirmOver" @btnErrClick="isShowOver = false">
			<view class="">
				<view class="text-center f-large m-b-20">
					本次审核{{examineNum}}条动态是否结束审核？
				</view>
				<view class="f-s text-center m-b-20">
					本次积累元石奖励：
					<text class="bold" style="color: #00B37A;">{{(examineNum * reward).toFixed(1)}}</text>
				</view>
				<view class="f-s text-center m-b-20">
					元石将在本月最后一日统一领取
				</view>
			</view>
		</tips-popup>
		
		<!-- 弹窗 -->
		<tipsPopup :show="tipsShow" :ifShowCancel="false" @btnSuccessClick="timeoutTipsConfirm">
		
			<view class="popup-text">
				{{tipsPopupText}}
			</view>
		
			<view class="popup-text-bottom" v-if="ifShowFrequency">
				目前剩余次数：
				<text>{{3 - examineInfo.count}}</text>
			</view>
		
			<view class="popup-text-bottom" v-else>
				「不良审核记录」
				<text>已超过三次</text>
				，取消您的审核员资格。
			</view>
		
		</tipsPopup>
		
	</view>
</template>

<script>
	import dynamicItem from './common/dynamic.vue'
	import errOrSuccessBtn from './common/btn.vue'
	import tipsPopup from './common/tipsPopup.vue'
	import complaint from '../community/common/complaint.vue'
	import rules from './common/rules.vue'
	import examineNav from './common/examineNav.vue'
	import {examineDynamicListApi,examineSubmitApi} from '../../api/examine.js'
	import timeoutLogic from '../../common/mixin/threeTimeout.js'
	export default {
		components: {
			dynamicItem,
			errOrSuccessBtn,
			tipsPopup,
			complaint,
			rules,
			examineNav
		},
		mixins:[timeoutLogic],
		data() {
			return {
				isShowBanPopup: false,
				isShowExcellentPopup: false,
				isShowOver: false,
				ifBan:false,
				ifExcellent:false,
				failShow: false, //封禁理由弹窗控制
				failList: [{
						name: '色情低俗',
						color: '#000',
						fontSize: '14'
					},
					{
						name: '垃圾广告',
						color: '#000',
						fontSize: '14'
					},
					{
						name: '攻击谩骂',
						color: '#000',
						fontSize: '14'
					},
					{
						name: '引战',
						color: '#000',
						fontSize: '14'
					},
					{
						name: '用户诱导、违规交易信息',
						color: '#000',
						fontSize: '14'
					},
					{
						name: '涉及政治政策风险',
						color: '#000',
						fontSize: '14'
					},
					{
						name: '信息灌水',
						color: '#000',
						fontSize: '14'
					},
					{
						name: '其他原因',
						color: '#000',
						fontSize: '14'
					}
				],
				failTitle: '请选择违规原因', //封禁弹窗title
				tipsShow: false, //提示弹窗控制
				ifBan: false, //是否封禁
				ifExcellent: false, //是否加精
				ifShowFrequency: false, //是否显示次数
				tipsPopupText: '超过3分钟未进行操作，审核已自动结束，本次审核将记录为「不良审核记录」，「不良审核记录」超过三次则取消审核员资格。',
				recode:[],
				
			}
		},
		onLoad() {
			// this.getData()
			let currentRoutes = getCurrentPages(); // 获取当前打开过的页面路由数组
			let currentRoute = currentRoutes[currentRoutes.length - 1].route //获取当前页面路由
			console.log(currentRoute)
		},
		methods: {
			
			//获取数据
			async getData(){
				uni.showLoading({
					title:'',
					mask:true
				})
				try{
					//获取列表
					const res = await examineDynamicListApi()
					this.recode = res.data
					this.submitData.type = 'article'
					this.submitData.id = res.data.length !== 0 ? res.data[0].dynamicId : 0
					uni.hideLoading()
					if(!res.data.length){
						uni.showToast({
							title:'暂无数据，请结束审核',
							icon:'none'
						})
					}
				}catch(e){
					uni.hideLoading()
					uni.showToast({
						title: e.message || e.data,
						icon: 'none'
					})
				}
			},
			
			// 不通过点击
			btnErrClick() {
				this.failShow = !this.failShow
			},

			// 通过点击
			async btnSuccessClick() {
				try{
					this.submitData.isPass = 1
					uni.$u.throttle(this.submitFun, 500)
					this.ifExcellent = false
					this.submitData.content = ''
				}catch(e){
					//TODO handle the exception
					console.log(e)
					this.submitData.content = ''
					uni.showToast({
						title: e.message || e.data,
						icon: 'none'
					})
				}
			},

			// 建议封建点击
			banClick() {
				this.ifBan = !this.ifBan
				this.isShowBanPopup = true
			},
			// 封禁
			handleBan(val) {
				this.submitData.content = val
				this.isShowBanPopup = false
				this.submitData.great = 0
				this.selectBanClick({name: val})
			},
			//建议精华点击
			excellentClick() {
				this.ifExcellent = !this.ifExcellent
				this.isShowExcellentPopup = true
			},
			// 加精
			handleExcellent(val) {
				this.submitData.content = val
				this.submitData.great = 1
				this.isShowExcellentPopup = false
				this.btnSuccessClick()
			},
			//封禁理由点击
			async selectBanClick(e) {
				try{
					this.submitData.isPass = 0
					this.submitData.notPassContent = e.name
					uni.$u.throttle(await this.submitFun, 500)
					this.ifBan = false
					this.submitData.content = ''
					this.submitData.notPassContent = ''
				}catch(e){
					console.log(e)
					this.submitData.content = ''
					this.submitData.notPassContent = ''
					uni.showToast({
						title: e.message || e.data,
						icon: 'none'
					})
					//TODO handle the exception
				}
			},
			failHide(){
				this.failShow = !this.failShow
			},
			showOverPopup() {
				this.isShowOver = true
			},
		}
	}
</script>

<style lang="scss">
	.empty{
		margin: 0 auto;
		margin-top: 200rpx;
		image{
			width: 418rpx;
			height: 308rpx;
		}
		view{
			margin-top: 10rpx;
			text-align: center;
			color: rgba(146, 146, 146, 1);
			font-size: 28rpx
		}
	}
	
	.btn {
		margin: 40rpx 0;
	}

	.bottom {
		padding-bottom: 52rpx;

		.bottom-title {
			text-align: center;
			margin-bottom: 48rpx;
			color: RGBA(157, 157, 157, 1);
		}

		.bottom-main {
			justify-content: space-around;

			.bottom-main-item {
				color: #000000;

				image {
					width: 120rpx;
					height: 120rpx;
					margin-bottom: 20rpx;
				}

				view {
					text-align: center;
				}
			}

		}

	}

	.popup-text {
		color: rgba(0, 0, 0, 1);
		font-size: 26rpx;
		text-align: center;
		line-height: 50rpx;
	}

	.popup-text-bottom {
		color: rgba(0, 0, 0, 1);
		font-size: 26rpx;
		text-align: center;
		margin: 40rpx 0;

		text {
			color: rgba(235, 91, 51, 1);
		}
	}
</style>
